using System.Linq.Expressions;
using NUnit.Framework;
using WWB.DisqusSharp.Model;
using WWB.DisqusSharp.Model.DisqusDTO;
using WWB.DisqusSharp.Model.DisqusService;

namespace WWB.DisqusSharp.Tests.ModelSerialization
{
    [TestFixture]
    [Category("Unit Tests")]
    public class CategoriesPayloadTest
    {
        private IDisqusServiceResult<Category[]> resultBase;
    
        [TestFixtureSetUp]
        public void ArrangeAndAct()
        {
            string json =
                "{\"message\":[{\"is_default\":true,\"title\":\"General\",\"id\":\"445069\",\"forum_id\":\"438500\"}],\"code\":\"ok\",\"succeeded\":true}";
            resultBase = new DisqusServiceResultWrapper<Category[]>(json);
        }

        [Test]
        public void Result_is_not_null()
        {
            Assert.That(resultBase, Is.Not.Null);
        }

        [Test]
        public void Result_has_expected_scalars()
        {
            Assert.That(resultBase.Error, Is.Null);
            Assert.That(resultBase.IsSuccessful);
        }

        [Test]
        public void Message_has_right_items()
        {
            Assert.That(resultBase.Payload, Is.Not.Null);
            Assert.That(resultBase.Payload.Length, Is.EqualTo(1));
            var cat = resultBase.Payload[0];
            Assert.That(cat.Id, Is.EqualTo("445069"));
            Assert.That(cat.ForumId, Is.EqualTo("438500"));
            Assert.That(cat.Title, Is.EqualTo("General"));
            Assert.That(cat.IsDefault, Is.True);
        }
    }
}